//-----------------------------------------------------------------------
// <copyright file="Provider.cs" company="CodePlex">
//     Copyright (c) Doug Holland, CodePlex. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace CodePlex.Diagnostics
{
    using System;
    using System.Xml;

    using System.Collections.Specialized;

    /// <summary>
    /// Represents a provider defined within a configuration file.
    /// </summary>
    internal sealed class Provider
    {
        #region internal Provider(XmlAttributeCollection attributes)

        /// <summary>
        /// Initializes a new instance of the <see cref="T:CodePlex.Diagnostics.Provider"/> class.
        /// </summary>
        /// <param name="attributes">The Xml attributes associated with the <see cref="T:CodePlex.Diagnostics.Provider"/> within the configuration file.</param>
        internal Provider(XmlAttributeCollection attributes)
        {
            this.Attributes = new NameValueCollection();

            // set the name of the provider
            this.Name = attributes["name"].Value;

            // set the type of the provider
            this.Type = attributes["type"].Value;

            foreach (XmlAttribute attribute in attributes)
            {
                if (attribute.Name != "name" && attribute.Name != "type")
                {
                    this.Attributes.Add(attribute.Name, attribute.Value);
                }
            }
        }

        #endregion        

        #region internal string Name

        /// <summary>
        /// Gets the name of the provider specified within the configuration section.
        /// </summary>
        internal string Name
        {
            get;
            private set;
        }

        #endregion

        #region internal string Type

        /// <summary>
        /// Gets the type of the provider specified within the configuration section.
        /// </summary>
        internal string Type
        {
            get;
            private set;
        }

        #endregion

        #region private NameValueCollection Attributes

        /// <summary>
        /// Gets or sets the attributes.
        /// </summary>
        /// <value>The attributes.</value>
        private NameValueCollection Attributes
        {
            get;
            set;
        }

        #endregion
    }
}